"use strict";
cc._RF.push(module, '1b994kOMZND2ZIjptSp797I', 'AttributeTotalView');
// scripts/AttributeTotalView.js

"use strict";

var t = require;
var e = module;
var o = exports;

var _i,
    n = void 0 && (void 0).__extends || (_i = function i(t, e) {
  return (_i = Object.setPrototypeOf || {
    __proto__: []
  } instanceof Array && function (t, e) {
    t.__proto__ = e;
  } || function (t, e) {
    for (var o in e) {
      Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
    }
  })(t, e);
}, function (t, e) {
  function o() {
    this.constructor = t;
  }

  _i(t, e), t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o());
}),
    a = void 0 && (void 0).__decorate || function (t, e, o, i) {
  var n,
      a = arguments.length,
      r = a < 3 ? e : null === i ? i = Object.getOwnPropertyDescriptor(e, o) : i;
  if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, i);else for (var s = t.length - 1; s >= 0; s--) {
    (n = t[s]) && (r = (a < 3 ? n(r) : a > 3 ? n(e, o, r) : n(e, o)) || r);
  }
  return a > 3 && r && Object.defineProperty(e, o, r), r;
};

Object.defineProperty(o, "__esModule", {
  value: !0
});

var r = t("GlobalUserData"),
    s = t("Util"),
    l = cc._decorator,
    c = l.ccclass,
    d = l.property,
    h = function (t) {
  function e() {
    var e = null !== t && t.apply(this, arguments) || this;
    return e.node_carHp = null, e.lab_carHp = null, e.node_carElec = null, e.lab_carElec = null, e.node_carDamage = null, e.lab_carDamage = null, e;
  }

  return n(e, t), e.prototype.updateTotal = function (t, e) {
    var o = s.Util.getBodyData(r["default"].curEquipBody[t]);
    if (!o) return this.setLabelString(this.lab_carElec, 0), this.setLabelString(this.lab_carHp, 0), this.setLabelString(this.lab_carDamage, 0), {
      elec: 0,
      hp: 0,
      damage: 0
    };

    for (var i = s.Util.transformHpNum(o.hp, o.level), n = o.elec, a = 0, l = 0; l < r["default"].curEquipWeapon[t].length; l++) {
      if (r["default"].curEquipWeapon[t][l]) {
        var c = s.Util.getWeaponData(r["default"].curEquipWeapon[t][l]);
        a += s.Util.transformDamageNum(c.damage, c.level), n -= c.elec;
      }
    }

    for (l = 0; l < r["default"].curEquipWheel[t].length; l++) {
      if (r["default"].curEquipWheel[t][l]) {
        var d = s.Util.getWheelData(r["default"].curEquipWheel[t][l]);
        n -= d.elec, i += s.Util.transformHpNum(d.hp, d.level);
      }
    }

    for (l = 0; l < r["default"].curEquipTools[t].length; l++) {
      if (r["default"].curEquipTools[t][l]) {
        var h = s.Util.getToolsData(r["default"].curEquipTools[t][l]);
        n -= h.elec, i += s.Util.transformHpNum(h.hp, h.level);
      }
    }

    var p = +this.lab_carHp.string,
        u = (this.lab_carElec.string, +this.lab_carDamage.string);
    return this.setLabelString(this.lab_carElec, n), e ? (this.updatenNumberAnim(p, i, this.lab_carHp, this.node_carHp), this.updatenNumberAnim(u, a, this.lab_carDamage, this.node_carDamage)) : (this.setLabelString(this.lab_carHp, i), this.setLabelString(this.lab_carDamage, a)), {
      elec: n,
      hp: i - p,
      damage: a - u
    };
  }, e.prototype.updatenNumberAnim = function (t, e, o, i) {
    var n = this;
    if (e > t) o.node.color = new cc.Color(170, 251, 0);else {
      if (!(e < t)) return void (o.node.color = new cc.Color(255, 255, 255));
      o.node.color = new cc.Color(255, 53, 0);
    }
    this.playAniLabelHint(i);
    var a = {
      num: 0
    };
    a.num = t, o.string = a.num.toString(), cc.tween(a).to(1, {
      num: e
    }, {
      progress: function progress(t, e, i, n) {
        return o.string = "" + Math.ceil(t + (e - t) * n), t + (e - t) * n;
      }
    }).delay(.1).call(function () {
      o.node.color = new cc.Color(255, 255, 255), n.setLabelString(o, e);
    }).start();
  }, e.prototype.playAniLabelHint = function (t) {
    t.getComponent(cc.Animation).play();
  }, e.prototype.setLabelString = function (t, e) {
    t.string = e.toString(), t.node.color = new cc.Color(255, 255, 255);
  }, a([d(cc.Node)], e.prototype, "node_carHp", void 0), a([d(cc.Label)], e.prototype, "lab_carHp", void 0), a([d(cc.Node)], e.prototype, "node_carElec", void 0), a([d(cc.Label)], e.prototype, "lab_carElec", void 0), a([d(cc.Node)], e.prototype, "node_carDamage", void 0), a([d(cc.Label)], e.prototype, "lab_carDamage", void 0), a([c], e);
}(cc.Component);

o["default"] = h;

cc._RF.pop();